package com.engine.modules.ytht.controller;

import com.engine.common.baseEntity.ResponseEntity.ResponseMsg;
import com.engine.modules.ytht.service.TobaccoRegionalPlanningImpl;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @author FY
 * @version 1.0.0
 * @ClassName TobaccoRegionalPlanningController.java
 * @Description TODO
 * @createTime 2022年01月11日
 */
@RestController
@Api(tags = "3、烟区规划操作")
@ApiSort(value = 3)
@CrossOrigin
@RequestMapping("/TobaccoRegionalPlanning")
@Slf4j
public class TobaccoRegionalPlanningController {

    @Autowired
    TobaccoRegionalPlanningImpl tobaccoRegionalPlanning;

    @ApiOperation(value = "获取地块图层矢量切片", notes = "通过切片号xyz，获取烟区规划数据，图层名为：TobaccoRegional")
    @GetMapping(value = "/SelectTobaccoRegionalPlanningVectorTiles/{tablePac}/{z}/{x}/{y}")
    @ApiOperationSupport(order = 1)
    public byte[] SelectTobaccoRegionalPlanningVectorTiles(@PathVariable("z") @ApiParam(name="z",value="16",required=true)int z,
                                                   @PathVariable("x") @ApiParam(name="x",value="50839",required=true)int x,
                                                   @PathVariable("y") @ApiParam(name="y",value="28021",required=true)int y,
                                                   @PathVariable(value = "tablePac")
                                                   @ApiParam(name="tablePac",value="53",required=true) String authPac) {
        try {
            log.debug("SelectFieldBlockLayerVectorTiles:pac:"+authPac+"|x:" + x + "|y:" + y + "|z:" + z);
            byte[] b = tobaccoRegionalPlanning.selectTobaccoRegionalVectorTileByXYZ(z, x, y, authPac);
            return b;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResponseMsg.error("服务器内部错误").toJsonBytes();
        }
    }

}
